FROM python:3.11-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Change the working directory to the `app` directory
WORKDIR /app

ENV PATH=/app/.venv/bin:$PATH

# 安装系统依赖
# RUN apt-get update && \
#     apt-get install -y \
#         gcc \
#         libmariadb-dev-compat \
#         libpq-dev \
#         libssl-dev \
#         libffi-dev \
#         build-essential \
#         rustc \
#         cargo && \
#     rm -rf /var/lib/apt/lists/*

# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
    --mount=type=bind,source=uv.lock,target=uv.lock \
    --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
    uv sync --locked --no-install-project

# Copy the project into the image
ADD . /app

EXPOSE 8000

# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
    uv sync --locked

# 启动命令
CMD ["fastapi", "dev", "run.py", "--port", "8000", "--host", "0.0.0.0"]